module(..., package.seeall)


IDGenerator = class("IDGenerator")

function IDGenerator.__init(self)
    self.count = multiset()
end

function IDGenerator.generate(self, obj)
    local name
    local cls = getmetatable(obj)
    if cls ~= nil then
        name = cls.__name
    end
    name = name or type(obj)
    return string.format("%s#%d", name, self.count:add(name))
end

IDGenerator.__call = IDGenerator.generate
